home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / DLFCN.ZIP / dlfcn / octave / oct-obj.h < prev    next >
C/C++ Source or Header  |  1997-08-20  |  4KB  |  165 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_oct_obj_h)
  24. #define octave_oct_obj_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <string>
  31.  
  32. #include "Array.h"
  33. #include "str-vec.h"
  34.  
  35. #include "ov.h"
  36.  
  37. class
  38. octave_value_list : public Array<octave_value>
  39. {
  40. public:
  41.  
  42.   octave_value_list (void)
  43.     : Array<octave_value> () { }
  44.  
  45.   octave_value_list (int n, const octave_value& val)
  46.     : Array<octave_value> (n, val) { }
  47.  
  48.   octave_value_list (const octave_value& tc)
  49.     : Array<octave_value> (1, tc) { }
  50.  
  51.   octave_value_list (double d)
  52.     : Array<octave_value> (1, octave_value (d)) { }
  53.  
  54.   octave_value_list (const Matrix& m)
  55.     : Array<octave_value> (1, octave_value (m)) { }
  56.  
  57.   octave_value_list (const DiagMatrix& d)
  58.     : Array<octave_value> (1, octave_value (d)) { }
  59.  
  60.   octave_value_list (const RowVector& v, int pcv)
  61.     : Array<octave_value> (1, octave_value (v, pcv)) { }
  62.  
  63.   octave_value_list (const ColumnVector& v, int pcv)
  64.     : Array<octave_value> (1, octave_value (v, pcv)) { }
  65.  
  66.   octave_value_list (const Complex& c)
  67.     : Array<octave_value> (1, octave_value (c)) { }
  68.  
  69.   octave_value_list (const ComplexMatrix& m)
  70.     : Array<octave_value> (1, octave_value (m)) { }
  71.  
  72.   octave_value_list (const ComplexDiagMatrix& d)
  73.     : Array<octave_value> (1, octave_value (d)) { }
  74.  
  75.   octave_value_list (const ComplexRowVector& v, int pcv)
  76.     : Array<octave_value> (1, octave_value (v, pcv)) { }
  77.  
  78.   octave_value_list (const ComplexColumnVector& v, int pcv)
  79.     : Array<octave_value> (1, octave_value (v, pcv)) { }
  80.  
  81.   octave_value_list (const char *s)
  82.     : Array<octave_value> (1, octave_value (s)) { }
  83.  
  84.   octave_value_list (const string& s)
  85.     : Array<octave_value> (1, octave_value (s)) { }
  86.  
  87.   octave_value_list (const string_vector& s)
  88.     : Array<octave_value> (1, octave_value (s)) { }
  89.  
  90.   octave_value_list (double base, double limit, double inc)
  91.     : Array<octave_value> (1, octave_value (base, limit, inc)) { }
  92.  
  93.   octave_value_list (const Range& r)
  94.     : Array<octave_value> (1, octave_value (r)) { }
  95.  
  96.   octave_value_list (const octave_value_list& obj)
  97.     : Array<octave_value> (obj) { }
  98.  
  99.   octave_value_list& operator = (const octave_value_list& obj)
  100.     {
  101.       if (this != &obj)
  102.     Array<octave_value>::operator = (obj);
  103.  
  104.       return *this;
  105.     }
  106.  
  107. // Assignment will resize on range errors.
  108.  
  109.   octave_value& operator () (int n) { return elem (n); }
  110.  
  111.   octave_value operator () (int n) const { return elem (n); }
  112.  
  113.   int all_strings (void) const;
  114.  
  115.   string_vector make_argv (const string&) const;
  116.  
  117. private:
  118.  
  119. // This constructor is private with no definition to keep statements
  120. // like
  121. //
  122. //   octave_value_list foo = 5;
  123. //   octave_value_list foo = 5.0;
  124. //
  125. // from doing different things.  Instead, you have to use the
  126. // constructor
  127. //
  128. //   octave_value_list (n, val);
  129. //
  130. // and supply a default value to create a vector-valued octave_value_list.
  131.  
  132.   octave_value_list (int n);
  133.  
  134.   void maybe_resize (int n)
  135.     {
  136.       if (n >= length ())
  137.     resize (n + 1, Matrix ());
  138.     }
  139.  
  140.   octave_value& elem (int n)
  141.     {
  142.       maybe_resize (n);
  143.       return Array<octave_value>::elem (n);
  144.     }
  145.  
  146.   octave_value& checkelem (int n);
  147.  
  148.   octave_value& xelem (int n);
  149.  
  150.   octave_value elem (int n) const
  151.     {
  152.       return Array<octave_value>::operator () (n);
  153.     }
  154.  
  155.   octave_value checkelem (int n) const;
  156. };
  157.  
  158. #endif
  159.  
  160. /*
  161. ;;; Local Variables: ***
  162. ;;; mode: C++ ***
  163. ;;; End: ***
  164. */
  165.